package com.zhen.controller;

import com.zhen.domain.User;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class User2Controller {

    private static final Log logger = LogFactory.getLog(User2Controller.class);

    @ModelAttribute
    public void userModel2(String loginname, String password, ModelMap modelMap){
        logger.info("userModel2");
        User user = new User();
        user.setLoginname(loginname);
        user.setPassword(password);
        modelMap.addAttribute("user",user);
    }

    @RequestMapping(value = "/login2")
    public String login2(ModelMap modelMap){
        User user = (User) modelMap.get("user");
        System.out.println(user);
        user.setUsername("测试");
        return "result2";
    }
}
